﻿using Autofac;
using Microsoft.Extensions.DependencyInjection;
using Serializer.Implementation;
using System;
using System.Diagnostics;
using System.Text.Json;

namespace Serializer
{
    class Program
    {
        static void Main(string[] args)
        {
            //int i = 1;
            //var bytes = MessageObjectSerializer.Serialize(i);
            //Console.WriteLine(bytes);
            //Console.WriteLine(System.Text.Encoding.Default);
            //var str = System.Text.Encoding.UTF8.GetString(bytes);
            //Console.WriteLine(bytes.ToString());
            //Console.WriteLine("Hello World!");
            var st = Stopwatch.StartNew();
            //JsonSerializerISerializer<string> jsonSerializer = new JsonSerializerISerializer<string>();
            //
            //for (var i = 0; i < 1000 * 1000*1; i++) 
            //{
            //    var guid = Guid.NewGuid().ToString();
            //    var bytes = jsonSerializer.Serialize(guid);
            //    var obj = jsonSerializer.Deserialize(bytes);
            //}
            //Console.WriteLine(st.ElapsedMilliseconds);

            //st = Stopwatch.StartNew();
            //for (var i = 0; i < 1000 * 1000*1; i++)
            //{
            //    var guid = Guid.NewGuid().ToString();
            //    var bytes = MessageObjectSerializer.Serialize(guid);
            //    var obj = MessageObjectSerializer.Deserialize<string>(bytes);
            //}
            //Console.WriteLine(st.ElapsedMilliseconds );
            //MyMessagePackSerializer<string> myMessagePackSerializer = new MyMessagePackSerializer<string>();
            //st = Stopwatch.StartNew();
            //for (var i = 0; i < 1000 * 1000*10; i++)
            //{
            //    var guid = Guid.NewGuid().ToString();
            //    var bytes = myMessagePackSerializer.Serialize(guid);
            //    var obj = myMessagePackSerializer.Deserialize(bytes);
            //}
            //Console.WriteLine(st.ElapsedMilliseconds );
            //Console.Read();

            //IServiceCollection services = new ServiceCollection();
            //services.AddMessagePack();
            //services.AddSingleton(typeof(TestClass));
            //var builder = services.BuildServiceProvider();
            //var testclass = builder.GetRequiredService<TestClass>();
            ContainerBuilder builder = new ContainerBuilder();
            builder.UseMessagePackCode();
            builder.RegisterType(typeof(TestClass)).InstancePerDependency();
            var container = builder.Build();
            var test = container.Resolve<TestClass>();
            test.test();
            Console.Read();



        }
    }
}
